import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.junit.Test;

import java.io.IOException;

/**
 * @author lemon
 * @version V1.0
 * @date 2020/08/31
 */
public class Demo3 {
    private String index = "user-index";
    //检查索引是否存在
    @Test
    public void test3() throws IOException {
        RestHighLevelClient client = ESClient.getClient();
        //1.准备查询的request对象
        GetIndexRequest request = new GetIndexRequest();
        request.indices(index);
        //2.通过client去操作
        boolean exist = client.indices().exists(request, RequestOptions.DEFAULT);
        System.out.println(exist);
    }
}
